package main

import (
	"github.com/kardianos/service"
	"go-iot-project/internal/args"
	"go-iot-project/pkg/utils"
	"go-iot-project/pkg/web"
	"log"
)

var serviceConfig = &service.Config{
	Name:        utils.AppName(),
	DisplayName: "物联网系统",
	Description: "物联网数据中台",
	Arguments:   nil,
}

func main() {
	args.Parse()
	program := &web.Program{}

	//
	serviceConfig.Arguments = []string{"-c", args.ConfigPath}

	s, err := service.New(program, serviceConfig)
	if err != nil {
		log.Fatal(err)
	}
	// 记录系统日志
	logger, err := s.Logger(nil)
	if err != nil {
		log.Fatal(err)
	}

	err = s.Run()
	if err != nil {
		_ = logger.Error(err)
	}
}
